Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor optimisations #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

minor optimisations #11

wants to merge 3 commits into from

Conversation

0xbyte0
Copy link

@0xbyte0 0xbyte0 commented Nov 8, 2022

Minor changes were made that would save some gas. It's not much, but it's honest work.

@@ -29,8 +29,13 @@ contract LlamaLendFactory is Ownable {
}

function emergencyShutdown(address[] calldata pools) external onlyOwner {
for(uint i = 0; i < pools.length; i++){
LendingPool(pools[i]).emergencyShutdown();
uint length = pools.length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i expect to never call this method, and if i call it will be one-off so gas doesnt matter much

@@ -40,7 +40,7 @@ contract ListNfts {
owner,
balance
);
if (tokenId >= start && tokenId < end) {
if (tokenId < end && tokenId >= start) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this contract is never called on-chain

@@ -101,7 +101,7 @@ contract LendingPool is OwnableUpgradeable, ERC721Upgradeable, Clone {
}

function calculateInterest(uint priceOfNextItems) internal view returns (uint interest) {
uint borrowed = priceOfNextItems/2 + totalBorrowed;
uint borrowed = (priceOfNextItems >> 1) + totalBorrowed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, does this have any side effects?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIV operator costs 5 gas while SHR costs 3 gas, so that saves 2 gas. And if that's called multiple times it'd sure amount to much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants